//
// Created by Administrator on 2023/7/28.
//
#include <iostream>
#include <vector>
#include <unordered_set>

using namespace std;

class Solution {
public:
    int arithmeticTriplets(vector<int> &nums, int diff) {
        unordered_set<int> us{nums.begin(), nums.end()};
        int ans = 0;
        for (int &x: nums) {
            if (us.count(x + diff) && us.count(x + 2 * diff))
                ans++;
        }
        return ans;
    }
};

int main() {
    vector<int> nums{0, 1, 4, 6, 7, 10};
    Solution s;
    cout << s.arithmeticTriplets(nums, 3) << endl;

}